public class Test {
    public static void main(String[] args) {
        String str = new String("hello");//创建两个对象
        String str2 = new String("hello") + new String("world");//创建6个对象
        //字符串类拼接变为StringBuffer类，赋值给String时，调用toString方法，该方法内部new String()

    }
    public static void main1(String[] args) {
        StringBuffer sb = new StringBuffer();
        sb.append("hello");
        sb.toString();
        System.out.println(sb);
    }
}
